<div class="container-fluid" style="padding: 20px 10px 0px 10px">
	<div class="row-fluid">
		<div class="well">
		    <ul class="nav nav-tabs">
		      <li class="active"><b>售后操作</b></li>
		    </ul>
		    <div id="myTabContent" class="tab-content">
				<div class="tab-pane active in" id="home">
					<form id="formid" action="/order/refund" method="post">
						<p>售后确认：<select name="status"><option value="5">同意售后</option><option value="3">拒绝售后</option></select></p>
						<p class="refund" style="display:none;">退货地址：<select  style="width:400px;" name="refund_address"><?php if($arr){foreach($arr as $ks=>$val){?><option value="<?=$val?>"><?=$val?></option><?php }}?></select></p>
						<p>操作备注：<textarea name="remark" placeholder="给客户留言，可不填" style="width:499px;margin-top:-19px;margin-left:70px" /></textarea></p>
						<input type="hidden" value="1" name="dosubmit" />
						<input type="hidden" value="<?=I('get.oid')?>" name="id" />
					</form>
				</div>
				<div class="btn-toolbar">
				    <button class="btn btn-primary" style="margin-left:72px" id="btn-save"><i class="icon-save"></i> 保存</button>
				</div>
			</div>
		</div>
	</div>
</div>
<script>
$(function(){
    var status= $('select[name=status] option:selected').val();
	if(status ==5){
	    $('.refund').show();
	}
    $('select[name=status]').change(function(){
	    var status= $('select[name=status] option:selected').val();
	    if(status ==5){
		    $('.refund').show();
		}else if(status ==3){
		   $('.refund').hide();
		 }
	});

	$('#btn-save').click(function(){
		setBtn($('#btn-save'));
		var param = {};
		param['dosubmit'] = $('#formid').find('input[name="dosubmit"]').val();
		param['id'] = $('#formid').find('input[name="id"]').val();
		param['status'] = $('#formid').find('select[name="status"]').val();
		param['refund_address'] = $('#formid').find('select[name="refund_address"]').val();
		param['remark'] = $('#formid').find('textarea[name="remark"]').val();
		$.post('/order/refund',param,function(data){
			if(data.code == '1'){
				showmsg(data.msg,data.code);
			}else if(data.code == '2'){
				//todo 调取退款流程
				$.post('/order/refundmon',{'dosubmit':param['dosubmit'],'id':param['id'],'order_status':'5','status':'8','remark':'订单未发货,买家申请退款'},function(data){
					showmsg(data.msg,data.code);
				},'json');
			}else if(data.code == '0'){
				showmsg(data.msg,data.code);
			}
			setTimeout(function(){
				parent.location.reload();
			},2000);
		},'json');
	});
})
</script>